package com.wish.bio;

import com.wish.common.MyUtils;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;


/**
 * @author tantexian
 * @since 2016/6/24
 */
public class BIORobotServer {

    public static void main(String[] args) {
        final int port = args.length >= 1 ? Integer.parseInt(args[0]) : MyUtils.getDefaultPort();

        try {
            ServerSocket serverSocket = new ServerSocket(port);
            System.out.println("I,m a smart robot and wait for you ask. [I'm listen on port " + port + "]\n");

            while (true) {
                Socket socket = serverSocket.accept();
                new Thread(new ServerHandle(socket)).start();
            }

        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}
